﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using YDWin.Base;
using YDServices;
using YDModel;
using DevExpress.Utils;
using YDCommon;
using YDServices.Enum; 
using static YDCommon.Utils;

namespace YDWin.EmployeeRole
{
    public partial class AddEmployeeRoleForm : AddForm
    {
        RoleService rs = new RoleService();
        EmployeeService svr = new EmployeeService();
        public T_Employee editTu = new T_Employee();
        public string state = "";
        public AddEmployeeRoleForm()
        {
            InitializeComponent(); 
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            T_User_Role userRole= new T_User_Role();
            userRole.User_ID = editTu.ID;
            userRole.Role_ID =long.Parse( cboRole.EditValue.ToString());  

             WaitDialogForm sdf = new WaitDialogForm("", "正在保存......");

            svr.EditRole(userRole);

            sdf.Close();

            if (svr.HasError)
            {
                Utils.ShowPrompt(MessageType.mtError, "角色信息保存失败：" + svr.Errors);
                svr.Errors.Clear();
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();

        }

        private void AddEmployeeRoleForm_Load(object sender, EventArgs e)
        {
            //订单分类
            var fDs = rs.getComboxList();
            cboRole.Properties.ValueMember = "ID";   //实际要用的字段
            cboRole.Properties.DisplayMember = "RoleName";    //要显示的字段
            cboRole.Properties.DataSource = fDs;

        }
 
    }
}